package com.aspose.cells;

class zbvq extends zbz {
   zbvq() {
      this.c(2173);
   }

   void a(int var1, zbvr var2) {
      this.b(20);
      this.b(this.d() + (short)a(var2));
      this.c = new byte[this.d()];
      this.c[0] = 125;
      this.c[1] = 8;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.c, 14, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2.getCount()), 0, this.c, 18, 2);
      a(var2, this.c, 20);
   }

   static int a(zbvr var0) {
      int var1 = 0;

      for(int var2 = 0; var2 < var0.getCount(); ++var2) {
         switch(var0.a(var2).a) {
         case 4:
         case 5:
         case 7:
         case 8:
         case 9:
         case 10:
         case 11:
         case 13:
            var1 += 20;
            break;
         case 6:
            var1 += (short)(52 + 22 * ((GradientFill)var0.a(var2).b).getGradientStops().getCount());
         case 12:
         default:
            break;
         case 14:
            var1 += 5;
            break;
         case 15:
            var1 += 6;
         }
      }

      return var1;
   }

   static int a(zbvr var0, byte[] var1, int var2) {
      for(int var3 = 0; var3 < var0.getCount(); ++var3) {
         zbvp var4 = var0.a(var3);
         var1[var2] = (byte)var4.a;
         switch(var0.a(var3).a) {
         case 4:
         case 5:
         case 7:
         case 8:
         case 9:
         case 10:
         case 11:
         case 13:
            var1[var2 + 2] = 20;
            zakp var5 = (zakp)var4.b;
            switch(var5.b()) {
            case 0:
            case 1:
               var1[var2 + 4] = 0;
               break;
            case 2:
               var1[var2 + 4] = 2;
               int var6 = var5.d();
               var1[var2 + 8] = (byte)(var6 >> 16 & 255);
               var1[var2 + 9] = (byte)(var6 >> 8 & 255);
               var1[var2 + 10] = (byte)(var6 & 255);
               var1[var2 + 11] = -1;
               break;
            case 3:
               var1[var2 + 4] = 1;
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.d()), 0, var1, var2 + 8, 4);
               break;
            case 4:
               var1[var2 + 4] = 3;
               System.arraycopy(com.aspose.cells.b.a.zc.a((short)((int)(var5.f() * 32767.0D))), 0, var1, var2 + 6, 2);
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.d()), 0, var1, var2 + 8, 4);
            }

            var2 += 20;
            break;
         case 6:
            var2 = a(var1, var2, (GradientFill)var4.b);
         case 12:
         default:
            break;
         case 14:
            var1[var2 + 2] = 5;
            var1[var2 + 4] = (Byte)var4.b;
            var2 += 5;
            break;
         case 15:
            var1[var2 + 2] = 6;
            System.arraycopy(com.aspose.cells.b.a.zc.a((Short)var4.b), 0, var1, var2 + 4, 2);
            var2 += 6;
         }
      }

      return var2;
   }

   private static int a(byte[] var0, int var1, GradientFill var2) {
      var0[var1] = 6;
      System.arraycopy(com.aspose.cells.b.a.zc.a(52 + 22 * var2.getGradientStops().getCount()), 0, var0, var1 + 2, 2);
      var1 += 4;
      switch(var2.getFillType()) {
      case 2:
         var0[var1] = 1;
         var1 += 12;
         System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.c().b / 100000.0D), 0, var0, var1 + 0, 8);
         System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.c().e / 100000.0D), 0, var0, var1 + 8, 8);
         System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.c().c / 100000.0D), 0, var0, var1 + 16, 8);
         System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.c().d / 100000.0D), 0, var0, var1 + 24, 8);
         break;
      default:
         var0[var1] = 0;
         double var3 = (double)var2.getAngle();
         System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, var0, var1 + 4, 8);
         var1 += 12;
         if (var2.d() != null) {
            System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.d().b / 100000.0D), 0, var0, var1 + 0, 8);
            System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.d().e / 100000.0D), 0, var0, var1 + 8, 8);
            System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.d().c / 100000.0D), 0, var0, var1 + 16, 8);
            System.arraycopy(com.aspose.cells.b.a.zc.a((double)var2.d().d / 100000.0D), 0, var0, var1 + 24, 8);
         }
      }

      var1 += 32;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2.getGradientStops().getCount()), 0, var0, var1, 4);
      var1 += 4;

      for(int var9 = 0; var9 < var2.getGradientStops().getCount(); ++var9) {
         GradientStop var4 = var2.getGradientStops().get(var9);
         int var5 = var4.a.d();
         switch(var4.a.b()) {
         case 0:
         case 1:
            var0[var1] = 0;
            break;
         case 2:
            int var6 = var5 & 255;
            int var7 = (var5 & '\uff00') >> 8;
            int var8 = (var5 & 16711680) >> 16;
            var5 = (var6 << 16) + (var7 << 8) + var8;
            var0[var1] = 2;
            break;
         case 3:
            var0[var1] = 1;
            break;
         case 4:
            var0[var1] = 3;
         }

         System.arraycopy(com.aspose.cells.b.a.zc.a(var5), 0, var0, var1 + 2, 4);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var4.getPosition() / 100.0D), 0, var0, var1 + 6, 8);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var4.a.f()), 0, var0, var1 + 14, 8);
         var1 += 22;
      }

      return var1;
   }
}
